<?php

namespace app\admin\model\forum;

use app\admin\model\users\Users;
use think\Model;


class Forum extends Model
{

    

    

    // 表名
    protected $name = 'forum';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'integer';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = false;
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'is_good_text'
    ];
    

    
    public function getIsGoodList()
    {
        return ['0' => __('Is_good 0'), '1' => __('Is_good 1')];
    }


    public function getIsGoodTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['is_good']) ? $data['is_good'] : '');
        $list = $this->getIsGoodList();
        return isset($list[$value]) ? $list[$value] : '';
    }

    function users()
    {
        return $this->belongsTo(Users::class,'users_id');
    }




}
